package com.ruoyi.web.controller.qsng;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.qsng.domain.KCenterOverview;
import com.ruoyi.qsng.service.IKCenterOverviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 中心概况Controller
 *
 * @author kanglou
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/qsng/overview")
@Api(tags = "pc--中心概况Controller")
public class KCenterOverviewController extends BaseController {
    @Autowired
    private IKCenterOverviewService kCenterOverviewService;

    /**
     * 查询中心概况列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:overview:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询中心概况列表")
    public TableDataInfo list(KCenterOverview kCenterOverview) {
        startPage();
        List<KCenterOverview> list = kCenterOverviewService.selectKCenterOverviewList(kCenterOverview);
        return getDataTable(list);
    }

    /**
     * 导出中心概况列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:overview:export')")
    @Log(title = "中心概况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出中心概况列表")
    public void export(HttpServletResponse response, KCenterOverview kCenterOverview) {
        List<KCenterOverview> list = kCenterOverviewService.selectKCenterOverviewList(kCenterOverview);
        ExcelUtil<KCenterOverview> util = new ExcelUtil<KCenterOverview>(KCenterOverview.class);
        util.exportExcel(response, list, "中心概况数据");
    }

    /**
     * 获取中心概况详细信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:overview:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取中心概况详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(kCenterOverviewService.selectKCenterOverviewById(id));
    }

    /**
     * 新增中心概况
     */
    @PreAuthorize("@ss.hasPermi('qsng:overview:add')")
    @Log(title = "中心概况", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增中心概况")
    public AjaxResult add(@RequestBody KCenterOverview kCenterOverview) {
        return toAjax(kCenterOverviewService.insertKCenterOverview(kCenterOverview));
    }

    /**
     * 修改中心概况
     */
    @PreAuthorize("@ss.hasPermi('qsng:overview:edit')")
    @Log(title = "中心概况", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改中心概况")
    public AjaxResult edit(@RequestBody KCenterOverview kCenterOverview) {
        return toAjax(kCenterOverviewService.updateKCenterOverview(kCenterOverview));
    }

    /**
     * 删除中心概况
     */
    @PreAuthorize("@ss.hasPermi('qsng:overview:remove')")
    @Log(title = "中心概况", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除中心概况")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(kCenterOverviewService.deleteKCenterOverviewByIds(ids));
    }
}
